package com.zmn.oms.business.impl.notifylog;

import com.zmn.oms.business.interfaces.notifylog.OrderNotifyLogBService;
import com.zmn.oms.common.dto.ResultDTO;
import com.zmn.oms.model.entity.notifylog.OrderNotifyLog;
import com.zmn.oms.services.interfaces.notifylog.OrderNotifyLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类描述：订单推送日志
 *
 * @author liuying
 * @date 2019/07/09 17:29
 */
@Service
public class OrderNotifyLogBServiceImpl implements OrderNotifyLogBService {

    @Autowired
    private OrderNotifyLogService orderNotifyLogService;

    @Override
    public void saveNotifyLog(ResultDTO resultDTO) {
        if (resultDTO == null || resultDTO.getData() == null || !(resultDTO.getData() instanceof OrderNotifyLog)) {
            return;
        }

        OrderNotifyLog orderNotifyLog = (OrderNotifyLog) resultDTO.getData();
        if (orderNotifyLog.getOrderId() == null) {
            return;
        }
        orderNotifyLog.setNotifyResultStatus(resultDTO.getStatus());
        orderNotifyLogService.insert(orderNotifyLog);
    }

    /**
     * 查指定订单的同步日志
     * @return
     */
    @Override
    public List<OrderNotifyLog> listByOrderId(Long orderId) {
        return orderNotifyLogService.listByOrderId(orderId);
    }
}
